﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ToolRental.Model;
using WebMatrix.WebData;

namespace ToolRental.Model
{
        public class InitializeDatabase
        {
            public InitializeDatabase()
            {
                Database.SetInitializer<MyDataContext>(null);

                try
                {
                    using (var context = new MyDataContext())
                    {
                        context.Database.CreateIfNotExists();
                    }
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
                }
            }
        }
}
